﻿using MediatR;
using System;
using W.Purchase.API.Application.Command.ClientCommand;
using W.Purchase.Domain;
using W.Purchase.Repository.Interface;

namespace W.Purchase.API.Application.CommandHandler.ClientCommandHandler
{
    public class UnitUpdateCommandHandler : IRequestHandler<UnitUpdateCommand, int>
    {
        private readonly IUnitRepository unit;
        public UnitUpdateCommandHandler(IUnitRepository unit)
        {
            this.unit = unit;
        }

        public async Task<int> Handle(UnitUpdateCommand request, CancellationToken cancellationToken)
        {
            return await unit.Update(new Domain.Unit()
            {
                UnitId = request.UnitId,
                UnitNo = request.UnitNo,
                UnitName = request.UnitName,
                UnitRemarks = request.UnitRemarks,
                office_id = request.office_id,
                user_id = request.user_id,
                CreateName = request.CreateName,
                CreateTime = request.CreateTime,
                UpdateName = "张三",
                UpdateTime = DateTime.Now,
                DeleteName = request.DeleteName,
                DeleteTime = request.DeleteTime,
                IsDelete = false,

            });
        }
    }
}
